﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.Common;
using LTJ.Entity;
using LTJ.FrameWork;
using System.Data;

namespace uswinweb.datacontrol
{
    public partial class pop_shipcompList : System.Web.UI.UserControl
    {
       public DataTable shipcompTab = new DataTable();
        public string strWhere = " 1=1 ";
        public int pagesize = 10;
        public int pageindex = SASRequest.GetInt("currentPage", 1);
        public string action = SASRequest.GetString("action");
        public string parpms = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("parms").Trim());
        public string searchtype = SASRequest.GetString("seatype").Trim();
        public string tcode = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("tcode").Trim());
        public string name = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("name").Trim());
        public string ename = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("ename").Trim());
        public string pageList = "";
        public string orderstr = " order by id asc ";
        public string bcode = "carrier";
        public pop_shipcompList()
        {
            int recordcount = 0;
            if (action == "search")
            {
                if (searchtype != "")
                {
                    if (tcode != "")
                    {
                        strWhere += " and tcode like '%" + tcode + "%' ";
                    }
                    if (name != "")
                    {
                        strWhere += " and name like '%" + name + "%' ";
                    }
                    if (ename != "")
                    {
                        strWhere += " and ename like '%" + ename + "%' ";
                    }
                }
                else
                {
                    strWhere += " and name like '%" + parpms + "%' ";
                }
            }

            if (bcode != "")
            {
                strWhere += " and code='" + bcode+"'";
            }
            recordcount = BaseDatas.GetBaseDataCount(strWhere);
            shipcompTab = BaseDatas.GetBaseDataByPage(pageindex, pagesize, strWhere, orderstr);
            pageList = GetPageList(recordcount, pagesize, pageindex);
        }
        public string GetPageList(int recordcount, int pagesize, int currentpage)
        {
            if (SASRequest.GetInt("postnumber", 0) > 0)
            {
                return LTJ.Common.Utils.LuffyPage3(recordcount, pagesize, currentpage, "pop_shipcompList.ascx", "postnumber=" + SASRequest.GetInt("postnumber", 0), "showdata");
            }
            else
            {
                return LTJ.Common.Utils.LuffyPage3(recordcount, pagesize, currentpage, "pop_shipcompList.ascx", "action=" + action + "&parms=" + parpms + "&tcode=" + tcode + "&name=" + name + "&ename=" + ename + "", "showdata");
            }
        }
    }
}